package com.alipay.config;

import com.alipay.api.AlipayClient;
import com.alipay.api.DefaultAlipayClient;

/**
 * @author lwj
 * @create 2025-10-10-23:11
 *
 * 支付宝客户端工厂
 */
public class AlipayClientFactory {
    private final AlipayConfig config;

    public AlipayClientFactory(AlipayConfig config) {
        this.config = config;
    }

    /**
     * 创建默认客户端（所有支付场景共用）
     * @return
     */
    public AlipayClient createClient(){
        return new DefaultAlipayClient(
                config.getGatewayUrl(),
                config.getAppId(),
                config.getMerchantPrivateKey(),
                "json",
                config.getCharset(),
                config.getAlipayPublicKey(),
                config.getSignType()
        );
    }
}
